package com.heima.media.controller;


import com.heima.media.service.WmNewsService;
import com.heima.model.common.dtos.PageRequestDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.media.dto.WmNewsDto;
import com.heima.model.media.dto.WmNewsQueryDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/api/v1/wmNews")
public class WmNewsController {


    @Autowired
    private WmNewsService wmNewsService;

    /**
     * 文章增加
     */
    @PostMapping(value = "/submit")
    public ResponseResult submit(@RequestBody WmNewsDto dto){
        return wmNewsService.submit(dto);
    }


    /**
     * 多条件分页查询
     * 1.接受分页查询对象PageRequestDto
     * 2.调用方法，创建IPage设置分页条件
     * 3.执行查询
     * 4.解析结果
     * @param dto
     * @return
     */
    @PostMapping("/search")
    public ResponseResult search(@RequestBody PageRequestDto<WmNewsQueryDto>dto){
      return   wmNewsService.search(dto);



    }
}
